package com.itHsuSE.encap;

public class Encap01 {
    public static void main(String[] args) {
        Person p=new Person();
    }
}


class Person{
    public String name;
    private int age;
    private double salary;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if(name.length()>=2&&name.length()<=6){
            this.name = name;
        }else {
            System.out.println("名字的长度不对");
            this.name="无名氏";
        }
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age>=1&&age<=120){
            this.age = age;
        }else {
            System.out.println("年龄要在1到120之间");
            this.age=18;
        }
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public String info(){
        return "信息为：name="+name+" age="+age+" salary="+salary;
    }
}